// C++中函数对象、成员函数指针该如何使用呢？请用代码给出示例
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

// Point类
class Point
{
    int m_x;
    int m_y;

public:
    // 构造函数：初始化点坐标，参数默认值为(0,0)
    Point(int x = 0, int y = 0)
        : m_x(x),
          m_y(y)
    {
    }
    void operator()()
    {
        cout << "() operator" << endl;
    }
    void func1()
    {
        cout << "func1" << endl;
    }
    void func2()
    {
        cout << "func2" << endl;
    }
    void func3()
    {
        cout << "func3" << endl;
    }
}; // end of class Point

void test1()
{
    Point p1;
    p1();
}
void test2()
{
    void (Point::*p)() = &Point::func1;
    Point p1;
    (p1.*p)();
}
void test3()
{
    typedef void (Point::*func)();
    Point p1;
    func f1 = &Point::func1;
   (p1.*f1)();
}
void test4()
{
    typedef void (Point::*func)();
    Point* p1 = new Point{};
    func f1 = &Point::func1;
   (p1->*f1)();
}




int main()
{
    test1();
    test2();
    test3();
    test4();

    return 0;
}
